//
//  BanBu_LanguageTypeViewController.m
//  BanBu
//
//  Created by Wang Xj on 13-11-13.
//
//

#import "BanBu_LanguageTypeViewController.h"

@interface BanBu_LanguageTypeViewController ()

@end

@implementation BanBu_LanguageTypeViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)viewWillAppear:(BOOL)animated
{
    [UIView setAnimationsEnabled:YES];
    [super viewWillAppear:animated];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.languageArray = @[[NSString stringWithFormat:@"%@",NSLocalizedString(@"中文->English", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"中文->日本語", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"中文->Española", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"中文->한국어", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"English->日本語", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"日本語->English", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"English->中文", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"日本語->中文", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"한국어->中文", nil)],[NSString stringWithFormat:@"%@",NSLocalizedString(@"Española->中文", nil)]];
}

-(void)viewDidAppear:(BOOL)animated
{
    if(IS_IOS_7)
    {
            [UIView animateWithDuration:0.5 animations:^{
            self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+20, self.view.frame.size.width, self.view.frame.size.height-20);
        }];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.languageArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    cell.textLabel.text =[self.languageArray objectAtIndex:indexPath.row];
    
    if (_selectedIndex == indexPath.row)
    {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else
    {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.selectedIndex = indexPath.row;

    if ([_delegate respondsToSelector:@selector(LanguageTypeView:didSelectIndex:)])
    {
        [_delegate LanguageTypeView:self didSelectIndex:indexPath.row];
    }
}

-(void)dealloc
{
    [_languageArray release],_languageArray = nil;
    [super dealloc];
}

@end
